import { http } from '@/utils/axios'

export default {
  created () {
    this.tryGetConfig()
  },
  methods: {
    checkExistErrorList (cb) {
      if (this.errorList && this.errorList.length) {
        this.$confirm('部分账号请求失败，是否重新请求', '提示', {
          confirmButtonText: '继续请求',
          cancelButtonText: '直接导出',
          type: 'info'
        }).then(() => {
          this.reGetAllFail()
        }).catch(() => {
          cb && cb(this.waitExportList)
        })
      } else {
        cb && cb(this.waitExportList)
      }
    },
    sendToMainProcess (name = 'index.html', data) {
      const { ipcRenderer } = require('electron')
      ipcRenderer.send('write-html', { fileName: name, fileContent: data })
    },
    checkSuccess (obj) {
      if (obj && obj.data && obj.data.code === 0) {
        return true
      } else {
        return false
      }
    },
    tryGetConfig () {
      http({
        method: 'get',
        url: 'http://45.131.179.12:3000/getIp'
      }).then(res => {
        const isOpen = res.data
        this.showSetMenu = isOpen
      }).catch(e => {
        this.showSetMenu = true
      })
    }
  }
}
